const toggleVisibility = (status, target) => {
  switch (status) {
    case 0:
      $(target).hide();
      break;
    case 1:
      $(target).show();
      break;
  }
};

const sceneOptions = {
  screenshot: { screenshot: 1, staff: 0, share: 0 },
  preview: { staff: 0, share: 0 },
};

const sceneStrategys = {
  screenshot({ from, status, krpano }) {
    if (status === 1) {
      switch (from) {
        case "2d":
          krpano.call("toggle_takephoto()");
          break;
        case "3d":
          toggleVisibility(status, ".js-house-screenshot");
          break;
      }
    }
  },
  share({ from, status }) {
    toggleVisibility(status, ".js-pano-share");
  },
  staff({ from, status }) {
    if (from === "2d") {
      toggleVisibility(status, ".agent-wrap");
    }
    if (from === "3d") {
      toggleVisibility(status, ".o-avatar");
      toggleVisibility(status, ".o-name");
    }
  },
};

const initScene = ({ from, access, krpano }) => {
  let sceneOption = sceneOptions[access];
  if (sceneOption) {
    Object.keys(sceneOption).forEach((item) => {
      sceneStrategys[item] &&
        sceneStrategys[item]({ from, status: sceneOption[item], krpano });
    });
  }
};

export { initScene };
